﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Acme.BookStore2.Migrations
{
    public partial class vehicleinspection : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AttachFile_VehicleInspectionRecord_VehicleInspectionRecordId",
                table: "AttachFile");

            migrationBuilder.DropTable(
                name: "AppVehicleRepairRecord");

            migrationBuilder.DropTable(
                name: "VehicleDriveRecord");

            migrationBuilder.DropTable(
                name: "VehicleInspectionRecord");

            migrationBuilder.DropTable(
                name: "VehicleMaintenanceRecord");

            migrationBuilder.CreateTable(
                name: "AppVehicleInspectionRecord",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    ExtraProperties = table.Column<string>(nullable: true),
                    ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorId = table.Column<Guid>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierId = table.Column<Guid>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false, defaultValue: false),
                    DeleterId = table.Column<Guid>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    Cleanliness = table.Column<string>(maxLength: 128, nullable: true),
                    TirePressure = table.Column<string>(maxLength: 128, nullable: true),
                    RemainFuel = table.Column<string>(maxLength: 128, nullable: true),
                    EngineLight = table.Column<string>(maxLength: 128, nullable: true),
                    WindshieldFluid = table.Column<string>(maxLength: 128, nullable: true),
                    Remark = table.Column<string>(nullable: true),
                    VehicleId = table.Column<Guid>(nullable: false),
                    TenantId = table.Column<Guid>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppVehicleInspectionRecord", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "VehicleDriveRecords",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    ExtraProperties = table.Column<string>(nullable: true),
                    ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorId = table.Column<Guid>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierId = table.Column<Guid>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false, defaultValue: false),
                    DeleterId = table.Column<Guid>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_VehicleDriveRecords", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "VehicleMaintenanceRecords",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    ExtraProperties = table.Column<string>(nullable: true),
                    ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorId = table.Column<Guid>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierId = table.Column<Guid>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false, defaultValue: false),
                    DeleterId = table.Column<Guid>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_VehicleMaintenanceRecords", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "VehicleRepairRecords",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    ExtraProperties = table.Column<string>(nullable: true),
                    ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorId = table.Column<Guid>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierId = table.Column<Guid>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false, defaultValue: false),
                    DeleterId = table.Column<Guid>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_VehicleRepairRecords", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_AppVehicleInspectionRecord_VehicleId",
                table: "AppVehicleInspectionRecord",
                column: "VehicleId");

            migrationBuilder.AddForeignKey(
                name: "FK_AttachFile_AppVehicleInspectionRecord_VehicleInspectionRecor~",
                table: "AttachFile",
                column: "VehicleInspectionRecordId",
                principalTable: "AppVehicleInspectionRecord",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AttachFile_AppVehicleInspectionRecord_VehicleInspectionRecor~",
                table: "AttachFile");

            migrationBuilder.DropTable(
                name: "AppVehicleInspectionRecord");

            migrationBuilder.DropTable(
                name: "VehicleDriveRecords");

            migrationBuilder.DropTable(
                name: "VehicleMaintenanceRecords");

            migrationBuilder.DropTable(
                name: "VehicleRepairRecords");

            migrationBuilder.CreateTable(
                name: "AppVehicleRepairRecord",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    CreatorId = table.Column<Guid>(type: "char(36)", nullable: true),
                    DeleterId = table.Column<Guid>(type: "char(36)", nullable: true),
                    DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true),
                    VehicleId1 = table.Column<Guid>(type: "char(36)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppVehicleRepairRecord", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AppVehicleRepairRecord_AppVehicle_VehicleId1",
                        column: x => x.VehicleId1,
                        principalTable: "AppVehicle",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "VehicleDriveRecord",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    CreatorId = table.Column<Guid>(type: "char(36)", nullable: true),
                    DeleterId = table.Column<Guid>(type: "char(36)", nullable: true),
                    DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true),
                    VehicleId1 = table.Column<Guid>(type: "char(36)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_VehicleDriveRecord", x => x.Id);
                    table.ForeignKey(
                        name: "FK_VehicleDriveRecord_AppVehicle_VehicleId1",
                        column: x => x.VehicleId1,
                        principalTable: "AppVehicle",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "VehicleInspectionRecord",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false),
                    Cleanliness = table.Column<string>(type: "longtext CHARACTER SET utf8mb4", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    CreatorId = table.Column<Guid>(type: "char(36)", nullable: true),
                    DeleterId = table.Column<Guid>(type: "char(36)", nullable: true),
                    DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    EngineLight = table.Column<string>(type: "longtext CHARACTER SET utf8mb4", nullable: true),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true),
                    RemainFuel = table.Column<string>(type: "longtext CHARACTER SET utf8mb4", nullable: true),
                    Remark = table.Column<string>(type: "longtext CHARACTER SET utf8mb4", nullable: true),
                    TirePressure = table.Column<string>(type: "longtext CHARACTER SET utf8mb4", nullable: true),
                    VehicleId1 = table.Column<Guid>(type: "char(36)", nullable: true),
                    WindshieldFluid = table.Column<string>(type: "longtext CHARACTER SET utf8mb4", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_VehicleInspectionRecord", x => x.Id);
                    table.ForeignKey(
                        name: "FK_VehicleInspectionRecord_AppVehicle_VehicleId1",
                        column: x => x.VehicleId1,
                        principalTable: "AppVehicle",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "VehicleMaintenanceRecord",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    CreatorId = table.Column<Guid>(type: "char(36)", nullable: true),
                    DeleterId = table.Column<Guid>(type: "char(36)", nullable: true),
                    DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true),
                    VehicleId1 = table.Column<Guid>(type: "char(36)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_VehicleMaintenanceRecord", x => x.Id);
                    table.ForeignKey(
                        name: "FK_VehicleMaintenanceRecord_AppVehicle_VehicleId1",
                        column: x => x.VehicleId1,
                        principalTable: "AppVehicle",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_AppVehicleRepairRecord_VehicleId1",
                table: "AppVehicleRepairRecord",
                column: "VehicleId1");

            migrationBuilder.CreateIndex(
                name: "IX_VehicleDriveRecord_VehicleId1",
                table: "VehicleDriveRecord",
                column: "VehicleId1");

            migrationBuilder.CreateIndex(
                name: "IX_VehicleInspectionRecord_VehicleId1",
                table: "VehicleInspectionRecord",
                column: "VehicleId1");

            migrationBuilder.CreateIndex(
                name: "IX_VehicleMaintenanceRecord_VehicleId1",
                table: "VehicleMaintenanceRecord",
                column: "VehicleId1");

            migrationBuilder.AddForeignKey(
                name: "FK_AttachFile_VehicleInspectionRecord_VehicleInspectionRecordId",
                table: "AttachFile",
                column: "VehicleInspectionRecordId",
                principalTable: "VehicleInspectionRecord",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
    }
}
